<template>
  <div class="app-container" style="margin-bottom: 30px;">
    <div class="search-container">
      <el-form ref="queryParamsRef" :inline="true" :model="queryParams" label-width="100px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="queryParams.name" clearable/>
        </el-form-item>
        <el-form-item label="联系电话" prop="telephone">
          <el-input v-model="queryParams.telephone" clearable/>
        </el-form-item>
        <el-form-item>
          <query-form-button @handleQuery="handleQuery" @resetQuery="resetQuery"/>
        </el-form-item>
      </el-form>
    </div>
    <el-table v-adaptive="480" :border="true" :data="onSiteAmbulanceStationList" :header-cell-style="$headerCellStyle"
              :stripe="true" highlight-current-row style="margin-bottom: 20px"> >
      <el-table-column :align="'center'" fixed="left" label="姓名" prop="name"/>
      <el-table-column :align="'center'" :show-overflow-tooltip="true" label="年龄" prop="age" width="45"/>
      <el-table-column :align="'center'" :show-overflow-tooltip="true" label="国籍" prop="nationality" width="45"/>
      <el-table-column :align="'center'" :show-overflow-tooltip="true" label="性别" prop="sex" width="45"/>
      <el-table-column :align="'center'" label="航班号" prop="hangbanhao"/>
      <el-table-column :align="'center'" :show-overflow-tooltip="true" label="住址和单位" prop="address"
                       width="120"/>
      <el-table-column :align="'center'" :show-overflow-tooltip="true" label="联系电话" prop="telephone"
                       width="80"/>
      <el-table-column :align="'center'" label="通知部门" prop="tongzhibumen"/>
      <el-table-column :align="'center'" label="接听人员" prop="jietingrenyuan"/>
      <el-table-column :align="'center'" label="出诊部门" prop="chuzhenbumen"/>
      <el-table-column :align="'center'" :show-overflow-tooltip="true" label="通知内容" prop="tongzhineirong"
                       width="100"/>
      <el-table-column :align="'center'" label="出诊位置" prop="chuzhenweizhi"/>
      <el-table-column :align="'center'" label="接警时间" prop="jiejingshijian" width="130">
        <template #default="scope">
          <span>{{ $parseTime(scope.row.jiejingshijian, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column :align="'center'" label="到达时间" prop="daodashijian" width="130">
        <template #default="scope">
          <span>{{ $parseTime(scope.row.daodashijian, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column :align="'center'" label="返回时间" prop="fanhuishijian" width="130">
        <template #default="scope">
          <span>{{ $parseTime(scope.row.fanhuishijian, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column :align="'center'" fixed="right" label="记录人" prop="createByName" width="70"/>

      <el-table-column :align="'center'" fixed="right" label="记录时间" prop="createTime" width="130">
        <template #default="scope">
          <span>{{ $parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" :align="'center'" fixed="right" class-name="small-padding fixed-width"
                       width="110">
        <template #default="scope">
          <el-button type="success" @click="introduce(scope.row)">
            <template #icon>
              <i-ep-edit/>
            </template>
            引用
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      v-model:limit="queryParams.pageSize"
      v-model:page="queryParams.pageNum"
      :total="total"
      @pagination="getList"
    />
  </div>
</template>

<script lang="ts">
export default {
  name: "OnSiteAmbulanceStationSelect"
}
</script>

<script lang="ts" setup>
import {
  selectPageOnSiteAmbulanceStation
} from "@/api/recordRegistration/onSiteAmbulanceStation.ts";

const {proxy} = getCurrentInstance() as any;
const emits = defineEmits(["introduce"])


const onSiteAmbulanceStationList = ref<any>([])

const props = defineProps({
  orgId: String,
  name: String,
  /**
   * 接口调用来源
   */
  apiSource: String
})

const queryParams = ref<any>({
  pageNum: 1,
  pageSize: 10,
  name: props.name,
  orgId: props.orgId,
  telephone: "",
})
const total = ref(0)
const formRef = ref()


function handleQuery() {
  queryParams.value.pageNum = 1;
  getList()
}

function resetQuery() {
  queryParams.value.name = ""
  queryParams.value.telephone = ""
  formRef.value.resetFields()
  getList()
}


/** 查询现场救护站门（急）诊记录(重庆江北)列表 */
function getList() {
  selectPageOnSiteAmbulanceStation(queryParams.value).then((response: any) => {
    onSiteAmbulanceStationList.value = response.rows;
    total.value = response.total;
  });
}


/** 引入患者信息 */
function introduce(row) {
  emits("introduce", row)
}

function getParentList(obj: any) {
  queryParams.value.name = obj.name
  getList()
}

defineExpose({
  getList,
  getParentList
})
</script>


